package com.example.demoyyy;

import org.junit.Test;
import redis.clients.jedis.Jedis;

import java.util.Set;

public class JavaRedisTest {
    // 编写测试函数
    //加注解变成测试函数
    @Test
    public   void   javaredistest01(){
        // 8.130.48.71  6379   auth  Wsx77582258.
        // 1.创建redis连接对象
        Jedis JavaRedisLianJie  = new Jedis("120.26.241.28",6379);
        JavaRedisLianJie.auth("zsp123456.");
        JavaRedisLianJie.set("name10","灿灿");
        String  Name4Value =  JavaRedisLianJie.get("name4");
        System.out.println("打印单元测试函数1运行结果"+Name4Value);
    }

    @Test
    public  void  JavaRedisTest02(){
        // 创建连接对象.输入 IP地址,端口号
        Jedis JavaRedisLianJie  = new Jedis("120.26.241.28",6379);
        JavaRedisLianJie.auth("zsp123456.");
        // 验证redis密码


        JavaRedisLianJie.sadd("操场1","都司路","李文","娜娜","雨晴","都司路","李文","娜娜","雨晴","都司路","李文","娜娜","雨晴");
        Set<String> smembers = JavaRedisLianJie.smembers("操场1");
        System.out.println("打印操场1集合中的元素"+smembers);
        Long   numbers  = JavaRedisLianJie.scard("操场1");
        // 集合自动去重
        System.out.println("打印操场1集合中的元素的数量:"+numbers);


        // 关闭连接对象
        JavaRedisLianJie.close();

    }

    @Test
    public  void  JavaRedisTest03(){
        Jedis JavaRedisLianJie  = new Jedis("120.26.241.28",6379);
        JavaRedisLianJie.auth("zsp123456.");
        JavaRedisLianJie.lpush("操场2","都司路","李文","娜娜","雨晴","都司路","李文","娜娜","雨晴","都司路","李文","娜娜","雨晴");
        Long  lnumbers = JavaRedisLianJie.llen("操场2");
        System.out.println("打印操场2的列表中元素数量:"+lnumbers);

    }

}
